package xjggb.algorithm.排序.sort.insert;

import xjggb.algorithm.排序.sort.Sort;

/*
* 插入排序
* */
public class InsertSort2<T extends Comparable<T>> extends Sort<T> {
    @Override
    protected void sort() {
        /*
        * 插入排序
        * */
        for (int begin = 1; begin < array.length; begin++) {
            int cur = begin;
            T v = array[cur];
            while (cur>0 && cmp(v,array[cur-1])<0){
                array[cur]=array[cur-1];
                cur--;
            }
            array[cur]=v;
        }
    }
}
